package com.hqd.ch03.v50.boot.web.servlet.context;

import com.hqd.ch03.v50.boot.web.context.WebServerInitializedEvent;
import com.hqd.ch03.v50.boot.web.server.WebServer;

public class ServletWebServerInitializedEvent extends WebServerInitializedEvent {

    private final ServletWebServerApplicationContext applicationContext;

    public ServletWebServerInitializedEvent(WebServer webServer,
                                            ServletWebServerApplicationContext applicationContext) {
        super(webServer);
        this.applicationContext = applicationContext;
    }

    /**
     * Access the application context that the server was created in. Sometimes it is
     * prudent to check that this matches expectations (like being equal to the current
     * context) before acting on the server itself.
     *
     * @return the applicationContext that the server was created from
     */
    @Override
    public ServletWebServerApplicationContext getApplicationContext() {
        return this.applicationContext;
    }

}
